package com.tsingteng.cosfun.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.tsingteng.cosfun.R;
import com.tsingteng.cosfun.helper.DialogHelper;

/**
 * 描述 :当有dialog有耗时的操作的时候继承此类可以有弹窗效果
 * 创建人: 肖利.
 * 时间:2018/8/11
 * qq(872179966)
 */

public class BaseDialog {

    private Dialog mLoadingDialog;

    public void showLoading(Context context){
        showLoading(context,"正在加载...");
    }

    public void showLoading(Context context,String text) {
        mLoadingDialog = DialogHelper.getLoadingDialog(context);
        TextView mTvLoading = mLoadingDialog.findViewById(R.id.tv_load_dialog);
        mTvLoading.setText(text);
        mLoadingDialog.show();
    }

    /**
     * 隐藏加载框
     */
    protected void hideLoadingDialog() {
        if (mLoadingDialog != null && mLoadingDialog.isShowing()) {
            mLoadingDialog.dismiss();
        }
    }
}
